package crowMessenger;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;

public class MainFrame extends JFrame{
	private static final long serialVersionUID = 7192040421385734276L;
	protected MainPanel panel;
	
	public MainFrame(){		
		setTitle("Crow Messenger");
		setJMenuBar(crowMenu());
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setLocation(700, 25);
		panel = new MainPanel(this);
		getContentPane().add(panel);
		pack();
		setVisible(true);
	}
	
	private JMenuBar crowMenu(){
		JMenuBar menu = new JMenuBar();
		JMenu chat = new JMenu("Chat");
		JMenu accounts = new JMenu("Accounts");
		JMenu view = new JMenu("View");
		JMenu tools = new JMenu("Tools");
		JMenu help = new JMenu("Help");
		
		JMenuItem accountManager = new JMenuItem("Manage Accounts");
		accountManager.setAccelerator(KeyStroke.getKeyStroke("control A"));
		accountManager.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				new AccountManagerFrame(panel);
			}
		});
		
		accounts.add(accountManager);
		
		menu.add(chat);
		menu.add(accounts);
		menu.add(view);
		menu.add(tools);
		menu.add(help);
		return menu;
	}
}
